<?php
class fwRoute {
    public function _getPrefix() {
        $pageURL = "http";
        if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; }
            $pageURL .= "://";
        if ($_SERVER["SERVER_PORT"] != "80") {
            $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
        } else {
            $pageURL .= $_SERVER["SERVER_NAME"];
        }
        return $pageURL;
    }
    public function buildUrl($url) {
        $a=explode("/", $url);
        $ac=array();
        foreach($a as $ab) {
            if(strlen($ab)) $ac[]=$ab;
        }
        return $this->_getPrefix()."/".implode("/", $ac)."/";
    }
    
    public function getUrl() { return $this->_getPrefix().$_SERVER["REQUEST_URI"]; }
    
}
?>
